﻿<UserControl x:Class="Sponsorship.Ui.Wpf.Views.PresentListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid x:Name="SponsorList" DataContext="{Binding [PresentListViewModel], Source={StaticResource Locator}}"> 
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Button Content="Zurück zum Hauptmenü" Command="{Binding BackCommand}"/>
        
        <StackPanel Orientation="Horizontal"
                    Grid.Row="1">
            <Button Command="{Binding NewPresentCommand}"
                    Content="Neues Geschenk anlegen"/>
        </StackPanel>
        
        <toolkit:DataGrid DataContext="{Binding}"
                          ItemsSource="{Binding Presents}"
                          Grid.Row="2"
                          AutoGenerateColumns="False"
                          CanUserAddRows="False"
                          SelectedItem="{Binding SelectedItem}">
            <toolkit:DataGrid.Columns>
                <toolkit:DataGridTextColumn Binding="{Binding Description}" Header="Beschreibung" MinWidth="200"/>
                <toolkit:DataGridTextColumn Binding="{Binding Amount}" Header="Betrag" MinWidth="200"/>
                <toolkit:DataGridTemplateColumn Header="">
                    <toolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Bearbeiten" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=toolkit:DataGrid}, Path=DataContext.EditCommand}"/>
                        </DataTemplate>
                    </toolkit:DataGridTemplateColumn.CellTemplate>
                </toolkit:DataGridTemplateColumn>
            </toolkit:DataGrid.Columns>
        </toolkit:DataGrid>
    </Grid>
</UserControl>
